﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:ICSharpCode.ILSpy.Controls">
	
	<Style x:Key="{x:Type local:SearchBox}" TargetType="{x:Type local:SearchBox}">
		<Setter Property="Background" Value="White" />
		<Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
		<Setter Property="BorderThickness" Value="1" />
		<Setter Property="SnapsToDevicePixels" Value="True" />
		<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:SearchBox}">
					<Border x:Name="Border"
					        Cursor="IBeam"
					        Background="{TemplateBinding Background}"
					        BorderBrush="{TemplateBinding BorderBrush}"
					        BorderThickness="{TemplateBinding BorderThickness}">
						<Grid x:Name="LayoutGrid">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*" />
								<ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualHeight}" />
							</Grid.ColumnDefinitions>
							<ScrollViewer Margin="2" x:Name="PART_ContentHost" Grid.Column="0" />
							<Label x:Name="WatermarkLabel"
							       Margin="2"
							       Grid.Column="0"
							       Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=WatermarkColor}"
							       Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=WatermarkText}"
							       Padding="2,0,0,0"
							       FontStyle="Italic" />
							<Border x:Name="PART_IconBorder"
							        Grid.Column="1"
							        BorderThickness="1"
							        VerticalAlignment="Stretch"
							        HorizontalAlignment="Stretch"
							        BorderBrush="Transparent"
							        Background="Transparent">
								<Image x:Name="SearchIcon"
								       Cursor="Arrow"
								       Stretch="None"
								       Width="12"
								       Height="12"
								       HorizontalAlignment="Center"
								       VerticalAlignment="Center"
								       ToolTip="Search"
								       Source="pack://application:,,,/ILSpy;component/images/search.png" />
							</Border>
						</Grid>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="HasText" Value="True">
							<Setter Property="Visibility" TargetName="WatermarkLabel" Value="Hidden" />
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="HasText" Value="True" />
							</MultiTrigger.Conditions>
							<Setter Property="Source"
							        TargetName="SearchIcon"
							        Value="pack://application:,,,/ILSpy;component/images/clearsearch.png" />
							<Setter Property="ToolTip" TargetName="SearchIcon" Value="Clear"/>
						</MultiTrigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>